<script>
let root = {val:55, left:{val:24}, right:{val:35}}
function levelOrder(root){
    let tempArr = []
    let resultArr = []
    tempArr.push(root)
    while(tempArr.length){
        resultArr.push([])
        let len = tempArr.length
        for(let i=0; i<len; i++){
            let node = tempArr.shift()
            resultArr[resultArr.length-1].push(node.val)
            if(node.left){
                tempArr.push(node.left)
            }
            if(node.right){
                tempArr.push(node.right)
            }
        }
    }
    return resultArr
}
let r = levelOrder(root)
console.log(r)
</script>